package xpassword

import (
	"crypto/sha1"
	"crypto/sha256"
	"encoding/hex"
	"fmt"
)

/* ============================================== *
 * 功能:密码加密
 * ============================================== */
func GenSaltPassword(password, salt string) string {
	s1 := sha256.New()
	s1.Write([]byte(password))
	str1 := fmt.Sprintf("%x", s1.Sum(nil))
	s2 := sha256.New()
	s2.Write([]byte(str1 + salt))
	return fmt.Sprintf("%x", s2.Sum(nil))
}

func Sha1(orig string, salt string) string {
	hn := sha1.New()
	hn.Write([]byte(orig))
	hn.Write([]byte(salt))
	data := hn.Sum([]byte(""))
	return hex.EncodeToString(data)
}
